]> dgit.raspbian.org Git - gnome-shell.git/commitdiff
extensionPrefs: Avoid awkward indentation in string literal
authorFlorian Müllner <fmuellner@gnome.org>
Tue, 12 Feb 2019 14:16:08 +0000 (15:16 +0100)
committerGeorges Basile Stavracas Neto <georges.stavracas@gmail.com>
Tue, 2 Jul 2019 12:17:46 +0000 (12:17 +0000)
The current code is carefully avoiding an overly wide line length as
well as adding literal new lines to the string due to indentation. It's
clever and barely legible.

Instead, use one string per line similar to how they appear in the actual
output, and join them together when setting the clipboard text.

https://gitlab.gnome.org/GNOME/gnome-shell/merge_requests/608

js/extensionPrefs/main.js

index b0be67f4913832b267e0a46028d010a405445431..af1ad08d5e25b2c6e499d202e525dcde4f00baf6 100644 (file)
@@ -168,13 +168,20 @@ var Application = class {
 
         copyButton.connect('clicked', w => {
             let clipboard = Gtk.Clipboard.get_default(w.get_display());
-            let backticks = '```';
-            clipboard.set_text(
-                // markdown for pasting in gitlab issues
-                `The settings of extension ${extension.uuid} had an error:\n${
-                backticks}\n${exc}\n${backticks}\n\nStack trace:\n${
-                backticks}\n${exc.stack}${backticks}\n`, -1
-            );
+            // markdown for pasting in gitlab issues
+            let lines = [
+                `The settings of extension ${extension.uuid} had an error:`,
+                '```',
+                `${exc}`,
+                '```',
+                '',
+                'Stack trace:',
+                '```',
+                exc.stack.replace(/\n$/, ''), // stack without trailing newline
+                '```',
+                ''
+            ];
+            clipboard.set_text(lines.join('\n'), -1);
         });
 
         let spacing = new Gtk.SeparatorToolItem({ draw: false });